package com.yb.web.global.servlet;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import com.yb.util.comm.Contants;
import com.yb.util.framework.OnLineCustomers;
import com.yb.util.framework.UserList;

public class SessionCount implements HttpSessionListener {

	/**
	 * 当创建一个session时在线人数加一
	 */
	public void sessionCreated(HttpSessionEvent event) {
		HttpSession session = event.getSession();
		UserList manager = UserList.getInstance();
		OnLineCustomers oc = new OnLineCustomers();
		oc.setSessionId(session.getId());
		manager.addManager(oc);
	}

	/**
	 * 当销毁一个session时在线人数减一
	 */
	public void sessionDestroyed(HttpSessionEvent event) {
		HttpSession session = event.getSession();
		UserList.getInstance().removeManager(session.getId());
	}

}
